﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace UI
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        Classinfo_BLL bll = new Classinfo_BLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            //调用BLL层的select方法
            GridView1.DataSource = bll.select();
            //数据绑定
            GridView1.DataBind(); 
        }
        
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //使用key获取id，前台需要使用DataKeyNames="Id"绑定Id
            //var id =e.Keys["Id"];
            //var idd = Convert.ToInt32(id);

            classinfo info = new classinfo();
            if (bll.delete(info) > 0)
            {
                //跳转到Url.PathAndQuery路径中的页面，使用此方法不会丢失参数(页面跳转后，地址和参数不变)
                var url = Request.Url.PathAndQuery;
                Response.Redirect(url);
                ////再次调用BLL层的select方法
                //GridView1.DataSource = Classinfo_BLL.select();
                ////数据绑定
                //GridView1.DataBind();
            }
        }
    }
}